package com.platform.service.impl;

import com.platform.cache.J2CacheUtils;
import com.platform.dao.DynamicRuleDao;
import com.platform.entity.DynamicRuleEntity;
import com.platform.service.DynamicRuleService;
import com.platform.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *  会员管理:任务规则配置列表
 * @author LiangXiaoJie
 * @email 740596501@qq.com
 * @date 2019-01-03 16:57:58
 */
@Service("dynamicRuleService")
public class DynamicRuleServiceImpl implements DynamicRuleService {
    @Autowired
    private DynamicRuleDao dynamicRuleDao;

    @Override
    public DynamicRuleEntity queryObject(Integer id) {
        return dynamicRuleDao.queryObject(id);
    }

    @Override
    public List<DynamicRuleEntity> queryList(Map<String, Object> map) {
        return dynamicRuleDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return dynamicRuleDao.queryTotal(map);
    }

    @Override
    public int save(DynamicRuleEntity sportsCreditRule) {
        J2CacheUtils.clear(Constants.REDIS_DYNAMIC_RULE_KEY);
        return dynamicRuleDao.save(sportsCreditRule);
    }

    @Override
    public int update(DynamicRuleEntity sportsCreditRule) {
        J2CacheUtils.clear(Constants.REDIS_DYNAMIC_RULE_KEY);
        return dynamicRuleDao.update(sportsCreditRule);
    }

    @Override
    public int delete(Integer id) {
        J2CacheUtils.clear(Constants.REDIS_DYNAMIC_RULE_KEY);
        return dynamicRuleDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        J2CacheUtils.clear(Constants.REDIS_DYNAMIC_RULE_KEY);
        return dynamicRuleDao.deleteBatch(ids);
    }

    @Override
    public DynamicRuleEntity selectForKey(String key) {
        return dynamicRuleDao.selectForKey(key);
    }
}
